home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
vansi.zip
/
NANSI.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-11-19
|
37KB
|
1,048 lines
page 66, 132
;--- nansi.asm ----------------------------------------------------------
; New ANSI terminal driver.
; Optimized for speed in the case of multi-character write requests.
; (C) 1986 Daniel Kegel, Pasadena, CA
; May be distributed for educational and personal use only
; The following files make up the driver:
; nansi.asm - all DOS function handlers except init
; nansi_p.asm - parameter parser for ANSI escape sequences
; nansi_f.asm - ANSI command handlers
; nansi_i.asm - init DOS function handler
;
; Daniel Kegel, Bellevue, Washington & Pasadena, California
; Revision history:
; 5 july 85: brought up non-ANSI portion except forgot backspace
; 6 july 85: split off ANSI stuff into other files, added backspace
; 11 july 85: fixed horrible bug in getchar; changed dosfns to subroutines
; 12 july 85: fixed some scrolling bugs, began adding compaq flag
; 9 aug 85: added cursor position reporting
; 10 aug 85: added output character translation
; 11 aug 85: added keyboard redefinition, some EGA 80x43 support
; 10 sept 85: Tandy 2000 support via compaq flag (finding refresh buffer)
; 30 Jan 86: removed Tandy 2000 stuff, added graphics mode support
; 12 feb 86: added int 29h handler, added PUSHA/POPA, added direct beep,
; direct cursor positioning, takeover of BIOS write_tty,
; noticed & squashed 2 related bugs in tab expansion
; 13 feb 86: Squashed them again, harder
;------------------------------------------------------------------------
include nansi_d.asm ; definitions
; from nansi_f.asm
extrn f_escape:near, f_in_escape:near
; from nansi_p.asm
extrn param_end:word, redef_end:word
; from nansi_i.asm
extrn dosfn0:near
; to nansi_p.asm
public f_loopdone
public f_not_ansi
public f_ansi_exit
; to both nansi_p.asm and nansi_f.asm
public cur_x, cur_y, max_x, cur_attrib
; to nansi_f.asm
public xy_to_regs, get_blank_attrib
public port_6845
public wrap_flag
public cur_parm_ptr
public cur_coords, saved_coords, max_y
public escvector, string_term
public cpr_esc, cprseq
public video_mode
public lookup
public in_g_mode
; to nansi_i.asm
public req_ptr, break_handler
public int_29
if takeBIOS
public new_vid_bios, old_vid_bios
endif
; to all modules
public xlate_tab_ptr
;--- seg_cs is the CS: override prefix
; (assembler forgets cs: on second "xlat dummy_cs_byte")
seg_cs macro
db 2eh
endm
;--- push_all, pop_all ------------------------------------------------
; Save/restore all user registers.
push_all macro
if is_8088
push ax
push bx
push cx
push dx
push bp
push si
push di
else
pusha
endif
endm
pop_all macro
if is_8088
pop di
pop si
pop bp
pop dx
pop cx
pop bx
pop ax
else
popa
endif
endm
keybuf struc ; Used in getchar
len dw ?
adr dw ?
keybuf ends
ABS40 segment at 40h
org 1ah
buffer_head dw ? ; Used in 'flush input buffer' dos call.
buffer_tail dw ?
org 49h
crt_mode db ?
crt_cols dw ?
crt_len dw ?
crt_start dw ?
cursor_posn dw 8 dup (?)
cursor_mode dw ?
active_page db ?
addr_6845 dw ?
crt_mode_set db ? ; = 7 only if monochrome display adaptor
crt_palette db ?
org 6ch
timer_low dw ? ; low word of time-of-day counter (18.2 hz)
org 84h
crt_max_y db ? ; CJD 11/19/89 - EGA/VGA max row #
ABS40 ends
page
CODE segment byte public 'CODE'
assume cs:code, ds:code
; Device Driver Header
org 0
dd -1 ; next device
dw 8013h ; attributes
dw strategy ; request header pointer entry
dw interrupt ; request entry point
db 'CON ' ; device name (8 char)
; Identification- in case somebody TYPEs the assembled driver
db 27, '[2J'
db "Nansi.sys v2.2"
ife is_8088
db "(80286)"
endif
db ': New ANSI driver (C) Daniel Kegel, Pasadena, CA 1986'
db 13, 10, 26
;----- variable area --------------------
req_ptr label dword
req_off dw ?
req_seg dw ?
wrap_flag db 1 ; 0 = no wrap past line end
escvector dw 0 ; state vector of ESCape sequencor
video_mode db 3 ; ROM BIOS video mode (2=BW, 3=color)
max_y db 24
max_cur_x label word ; used to get both max & cur at once
max_x db 79 ; line width (79 for 80x25 modes)
cur_coords label word
cur_x db 0 ; cursor position (0 = left edge)
cur_y db 0 ; (0 = top edge)
saved_coords dw ? ; holds XY after a SCP escape sequence
string_term db 0 ; either escape or double quote
cur_attrib db 7 ; current char attributes
cur_page db 0 ; current display page
video_seg dw ? ; segment of video card
f_cptr_seg dw ? ; part of fastout write buffer pointer
cur_parm_ptr dw ? ; last byte of parm area now used
port_6845 dw ? ; port address of 6845 card
xlate_tab_ptr dw ? ; pointer to output translation table
if takeBIOS
old_vid_bios dd ? ; pointer to old video bios routine
endif
brkkeybuf db 3 ; control C
fnkeybuf db ? ; holds second byte of fn key codes
cpr_buf db 8 dup (?), '['
cpr_esc db 1bh ; descending buffer for cpr function
; following four keybufs hold information about input
; Storage order determines priority- since the characters making up a function
; key code must never be separated (say, by a Control-Break), they have the
; highest priority, and so on. Keyboard keys (except ctrl-break) have the
; lowest priority.
fnkey keybuf <0, fnkeybuf> ; fn key string (0 followed by scan code)
cprseq keybuf <0> ; CPR string (ESC [ y;x R)
brkkey keybuf <0, brkkeybuf> ; ^C
xlatseq keybuf <0> ; keyboard reassignment string
;------ xy_to_regs --------------------------------------------
; on entry: x in cur_x, y in cur_y
; on exit: dx = chars left on line, di = address
; Alters ax, bx.
xy_to_regs proc near
; Find number of chars 'till end of line, keep in DX
mov ax, max_cur_x
mov bx, ax ; save max_x & cur_x for next block
mov ah, 0 ; ax = max_x
xchg dx, ax
mov al, bh
mov ah, 0 ; ax = cur_x
sub dx, ax
inc dx ; dx is # of chars till EOL
; Calculate DI = current address in text buffer
mov al, bl ; al = max_x
inc al
mul cur_y
add al, bh ; al += cur_x
adc ah, 0 ; AX is # of chars into buffer
add ax, ax
xchg di, ax ; DI is now offset of cursor.
ret
xy_to_regs endp
;------- dos_fn_tab -------------
; This table is used in "interrupt" to call the routine that handl